Release 10.1A: OpenEdge Development:
Java Open Clients


Defining the schema for a temp-table parameter mapped to a java.sql.ResultSet

Defining the schema for a Progress 4GL TABLE or TABLE-HANDLE parameter passed as a java.sql.ResultSet is a multi-step process.

Note: If you pass a temp-table as an java.sql.ResultSet parameter you must access the parameter as a data stream. For more information on accessing temp-tables as java.sqlResultSet parameters, see Appendix C "Passing Temp-tables as SQL ResultSet Parameters."

To define the schema for a temp-table parameter passed as a java.sql.ResultSet:

  1. Define a com.progress.open4gl.ProResultSetMetaDataImpl object.
  2. Add field descriptions to the ProResultSetMetaDataImpl object.
  3. If the parameter is for input or input-output, define a java.sql.ResultSet to hold the parameter value.
  4. Add the ProResultSetMetaDataImpl object as a temp-table parameter to your ParamArray object using the appropriate set parameter method.
  5. Note: You can also pass a temp-table parameter as a ProDataGraph. For more information, see the "Defining the schema for a temp-table parameter mapped to a ProDataGraph" section.

Defining a ProResultSetMetaDataImpl object

For each temp-table parameter you must define a com.progress.open4gl.ProResultSetMetaDataImpl object:

Syntax
public ProResultSetMetaDataImpl (int numFields) 

numFields

Specifies the number of fields (or columns) in the temp-table.

Adding field descriptions to the ProResultSetMetaDataImpl object

Add the meta data for each field of the temp-table by calling the setFieldMetaData() method on the ProResultSetMetaDataImpl object for each column in the temp-table:

Syntax
public void setFieldMetaData(int position, String name, int extentValue,  
                             int proType) 

position

Specifies the 1-based position of a mapped field in a Progress 4GL temp-table.

name

Specifies a field name, typically set to the corresponding 4GL field name in the temp-table.

extentValue

Specifies the extent of an array, 0 or 1 for a scalar value.

proType

Specifies the value of a class constant defined in the com.progress.open4gl.Parameter class. The specified class constant indicates the 4GL data type of the mapped temp-table field. For more information on these class constants, see the sections on specifying field data type meta data for temp-tables in Chapter 4, " Passing Parameters." To identify the Java data type that the column property assumes for the specified 4GL data type, see the information on mapping temp-tables to java.sql.ResultSet objects in Appendix C "Passing Temp-tables as SQL ResultSet Parameters."

Adding the ProResultSetMetaDataImpl object as a temp-table parameter

Add the ProResultSetMetaDataImpl object by passing it as a parameter of the addTable() or addTableHandle() method that you use to add the temp-table parameter to the ParamArray object. For more information, see the "TABLE or TABLE-HANDLE" section

This is an example that adds a temp-table as an input parameter:

Sample OpenAPI fragment adding a temp-table parameter as an SQL ResultSet
// Create the ParamArray 
ParamArray parms = new ParamArray(1); 
// Set up the meta data 
ProResultSetMetaDataImpl metaData1; 
metaData1 = new ProResultSetMetaDataImpl (6); 
metaData1.setFieldMetaData 
             (1, "OrderNum", 0, Parameter.PRO_INTEGER); 
metaData1. setFieldMetaData 
             (2, "SalesRep", 0, Parameter.PRO_CHARACTER); 
metaData1. setFieldMetaData 
             (3, "OrderDate", 0, Parameter.PRO_DATE); 
metaData1. setFieldMetaData 
             (4, "ShipDate", 0, Parameter.PRO_DATE); 
metaData1. setFieldMetaData 
             (5, "TotalDollars", 0, Parameter.PRO_DECIMAL); 
metaData1. setFieldMetaData 
             (6, "OrderStatus", 0, Parameter.PRO_CHARACTER); 
// Create result set for an input parameter 
ResultSet rs = new ResultSet(); 
... 
// Add the parameter to the ParamArray 
parms.addTable (0, rs, ParamArrayMode.INPUT, metaData1); 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095